package com.fangs.yehwangglobal.widget.eventbus;

import org.greenrobot.eventbus.EventBus;

/**
 * eventBus统一管理
 */
public class EventManager {
    /**
     * 注册
     *
     * @param object
     */
    public static void register(Object object) {
        if (!EventBus.getDefault().isRegistered(object)) {
            EventBus.getDefault().register(object);
        }
    }

    /**
     * 注销
     *
     * @param object
     */
    public static void unregister(Object object) {
        if (EventBus.getDefault().isRegistered(object)) {
            EventBus.getDefault().unregister(object);
        }
    }

    /**
     * 发送消息
     *
     * @param object
     */
    public static void post(Object object) {
        EventBus.getDefault().post(object);
    }

    /**
     * 发送粘性消息
     *
     * @param object
     */
    public static void postSticky(Object object) {
        EventBus.getDefault().postSticky(object);
    }

    /**
     * 移除粘性消息 避免重复接收问题
     *
     * @param object
     */
    public static void removeSticky(Object object) {
        EventBus.getDefault().removeStickyEvent(object);
    }
}
